package com.example.pjy.service.impl;

import com.example.pjy.mapper.StudentMapper;
import com.example.pjy.pojo.Student;
import com.example.pjy.service.StudentService;
import com.example.pjy.utils.ThreadLocalUtil;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Service
public class StudentServiceImpl implements StudentService {

    @Resource
    private StudentMapper StudentMapper;//依赖注入


    @Override
    public void add(Student student){
        //补充属性值
        student.setCreateTime(LocalDateTime.now());
        student.setUpdateTime(LocalDateTime.now());
        StudentMapper.add(student);
    }




    @Override
    public List<Student> list(){
        return StudentMapper.list();//只能查询当前用户的所有分类 告诉mapper层当前用户是谁
    }





    @Override
    public Student findById(Integer student_id){
        Student st = StudentMapper.findById(student_id);
        return st;
    }




    @Override
    public void updatest(Student student){
        student.setUpdateTime(LocalDateTime.now());
        StudentMapper.updatest(student);
    }




    @Override
    public void delete(int StudentId){
        StudentMapper.delete(StudentId);
    }


    @Override
    public boolean isExist(int StudentId){
        return StudentMapper.isExist(StudentId);
    }


    @Override
    public boolean isTotalScoreExist(Integer studentId){
        return StudentMapper.isTotalScoreExist(studentId);
    }




    @Override
    public List<Student> selectbyname(String keyword){
         return StudentMapper.selectbyname(keyword);
    }
}
